<?php
/**
 * Created by PhpStorm.
 * User: 雨寒
 * Date: 2018/7/16
 * Time: 上午9:05
 */
namespace app\admin\controller;
use think\Db;
use app\common\model\Message;
class Rate extends Common
{
    //提现设置
    public function index()
    {
        //渲染
        if (request()->isGet())
        {
            //设置标题

            $this->templateTitle("系统参数");
            $rate=Db::name('rate')->find();
            $this->assign('rate',$rate);
            return $this->fetch();
        }

        //提交数据
        if (request()->isAjax())
        {
            //设置信息
            $data = array(
                "auto_receive_time"=>intval(input('auto_receive_time')),
                "score_rate" => input('score_rate'),
                "withdraw_rate" => input('withdraw_rate'),
                "user_withdraw_min" => input('user_withdraw_min'),
                "sign_normal" => input('sign_normal'),
                "order_score_rate" => input('order_score_rate'),
                "order_time" => input('order_time'),
            );
            $res=Db::name('rate')->where('id',1)->update($data);
            if($res)
            {
                Message::admin_log(0,"后台修改系统参数！");
                $this->ajaxSuccess("参数修改成功！");
            }else{
                $this->ajaxError("参数修改失败！");
            }

        }
    }
}